<?php
namespace frontend\controllers;


use yii\web\Controller;
use frontend\models\Country;
use common\models\LoginForm;
use frontend\models\ContactForm;
/**
 * Site controller
 */
class DemoController extends Controller
{
    /**
     * @inheritdo
     */
    public function actionIndex()
    {    
      $res = new Country();
      $res->code = "AA";
      $res->name="abcdetrs";
      $res->population="278357000";
      $data = $res->insert();
      print_r($res['id']);die;
       $primaryConnection = \Yii::$app->db;

       $commit = $primaryConnection->createCommand('SELECT * FROM country');
 
       $data=$commit->queryAll();
        print_r($data);die;
    }

    public function actionList()
    {
      return $this->render("list");
    }

    public function actionLogin()
    { 
      $model = new LoginForm();
     return $this->render('login', [
            'model' => $model,
        ]);
    }

    public function actionLogin_in()
    {
      $data=$_POST;
      $model = new LoginForm();
      $model->login();
      if ($model->validate()) {
    // all inputs are valid
        $errors="ok";
    } else {
        // validation failed: $errors is an array containing error messages
        $errors = $model->errors;
    }
      print_r($errors);
    }

    public function actionSign()
    { 
      $model = new LoginForm();
       return $this->render('sign', [
            'model' => $model,
        ]);
    }

     
}
